<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__LAYUIMINI__/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="__LAYUIMINI__/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__LAYUIMINI__/css/public.css" media="all">
    <style>
        .layui-upload-img{width: 92px; height: 92px;}
    </style>
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <!-- layui-form-pane 方框式表单 -->
            <form class="layui-form layui-form-pane" action="" lay-filter="example">

                <div class="layui-form-item">
                    <label class="layui-form-label">分类名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="cate_name" value="{$one['cate_name']}" lay-verify="required" autocomplete="off" placeholder="请输入分类名称"
                            class="layui-input">
                    </div>
                </div>


                <!-- <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="number" name="sort" value="0" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" checked="" name="status" lay-skin="switch" lay-filter="switchTest"
                            lay-text="正常|关闭">
                    </div>
                </div> -->
                <input type="hidden" name="id" id="" value="{$one['id']}">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="__LAYUIMINI__/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="__LAYUIMINI__/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
        layui.use(['form'], function () {
            var form = layui.form,
                $ = layui.$,
                layer = layui.layer;
            //监听指定开关
            form.on('switch(switchTest)', function (data) {

            });

            //监听提交
            form.on('submit(demo1)', function (data) {
                var data = data.field
                $.ajax({
                    type: "post",
                    url: "saveBannerCate",
                    data: data,
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 1) {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            // parent.layer.close(index); //再执行关闭 
                            // 关闭后调用
                            layer.msg(res.msg)
                            setTimeout(function () {
                                parent.layer.close(index);
                            }, 500)
                        } else {
                            layer.msg(res.msg)
                        }


                    }
                });
                return false;
            });


        });
    </script>

</body>

</html>